<?php

namespace app\admin\controller\system;

use app\admin\controller\Controller;
use app\common\controller\ResourceController;
use app\model\Admin;
use think\Exception;

class AdminUser extends Controller
{

    use ResourceController;

    /**
     * 不能修改的字段
     * @var string[]
     */
    public $noEditField = ['username'];

    public $with = ['role'];

    /**
     * 不允许删除
     * @var bool
     */
    public $deleteNotAllowed = true;


    /**
     * 默认的查询搜索条件
     * @var array
     */
    public $defaultWhere = ['is_deleted' => 0];

    /**
     * 执行删除的字段
     * @var array
     */
    public $deleteField = ['is_deleted' => 1];




    public function __construct()
    {

        $this->model = new Admin();

    }

    public function deleteBefore($obj){
        if ($obj->id == 1){
            throw new Exception('超级管理员不允许被删除');
        }

    }







}